<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.List,java.util.Map;" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %> 

<div class="toolbar">
<c:if test="${userinfo.ui_username eq 'admin' or model.r_create eq 1}">
	<button href="<%=request.getContextPath()%>/c?${ model.m_action }&m_id=${model.m_id }&o=form&p=add" class="btn btn-large btn-success add"><i class="icon-plus"></i> <span>新建</span></button>
</c:if>
</div>

<table cellpadding="0" cellspacing="0" border="0" class="datatable">
	<thead>
		<tr>
		<c:forEach var="control" items="${controls }" >
		<c:if test="${control.mc_pri ==1}">
		<c:set var="pri" value="${control.mc_attr_name }" scope="request"/>
		</c:if>
		<c:if test="${control.mc_show ==1}">
		<c:if test="${control.mc_auto ==0}">
		<th col="${control.mc_attr_name }">${control.mc_prompt}</th>
		</c:if>
		</c:if>
		</c:forEach>
		<th>操作</th>
		</tr>
	</thead>
	<tbody>
	<c:set var="f" value="0" />
	<c:forEach var="e" items="${es }">
	<c:set var="entry" value="${e }" scope="request"/>
	<% Map<String,Object> entry =  ((Map<String,Object>)request.getAttribute("entry")); %>
	<tr  class='grade<c:if test="${f%2==0}">B</c:if><c:if test="${f%2!=0}">A</c:if>'>
		<c:set var="f" value="${f+1 }" />
		<c:forEach var="control" items="${controls }" >
		<c:if test="${control.mc_show ==1 }">
		<c:if test="${control.mc_auto ==0 }">
		 <c:set var="c" value="${control.mc_attr_name}" scope="request"/>
		<td>
			<c:if test="${control.c_tag eq 'file' }"><a href="<%=request.getContextPath()%>/f?guid=<%= entry.get("guid") %>"><%= entry.get(request.getAttribute("c").toString()) %></a></c:if>
			<c:if test="${control.c_tag ne 'file' }"><%= entry.get(request.getAttribute("c").toString()) %></c:if>
		</td>
		</c:if>
		</c:if>
		</c:forEach>
		<td>
		<c:if test="${userinfo.ui_username eq 'admin' or model.r_update eq 1}">
			<button class="btn btn-small btn-primary edit" href="<%=request.getContextPath()%>/c?${ model.m_action }&o=form&p=edit&m_id=${model.m_id }&pri=${pri }&v=${model.m_view}&key=<%= entry.get(request.getAttribute("pri").toString()) %>"><i class="icon-pencil"></i></button>
		</c:if>
		<c:if test="${userinfo.ui_username eq 'admin' or model.r_delete eq 1}">
			<button class="btn btn-small btn-danger delete" href="<%=request.getContextPath()%>/c?${ model.m_action }&o=delete&isajax=1&m_id=${model.m_id }&pri=${pri }&v=${model.m_view}&key=<%= entry.get(request.getAttribute("pri").toString()) %>"><i class="icon-remove"></i></button>
		 </c:if>
		 </td>
	</tr>
	</c:forEach>
		
	</tbody>
</table>

<script>
$(".datatable").dataTable(datatable_config);
</script>